/*
 * @Description:测试类
 * 
 * @Author: rendc
 * 
 * @Date: 2025-08-06 11:45:08
 * 
 * @LastEditors: rendc
 * 
 * @LastEditTime: 2025-08-06 11:49:30
 */

public class Test {

  public static void main(String[] args) {
    // 同过接口实现类实现接口
    ISleep iSleep = new SleepImpl();
    iSleep.sleep();
    // 通过匿名内部类简化的写法
    ISleep isSleep2 = new ISleep() {
      @Override
      public void sleep() {
        System.out.println("睡觉");
      }
    };
    isSleep2.sleep();
    // 更加简化
    new ISleep() {
      @Override
      public void sleep() {
        System.out.println("睡觉");
      }
    }.sleep();
  }
}